package com.wechat.user.controller;

import com.wechat.common.web.result.Result;
import com.wechat.user.request.RegisterRequest;
import com.wechat.user.request.RegisterSmsRequest;
import com.wechat.user.service.RegisterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/register")
@Tag(name = "用户注册", description = "用户注册")
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    @PostMapping
    @Operation(
            summary = "用户注册",
            description = "用户注册"
    )
    public Result<Void> register(@Validated @RequestBody RegisterRequest request) {
        registerService.register(request);
        return Result.success();
    }

    // 发送验证码
    @PostMapping("/sms")
    @Operation(
            summary = "注册验证码",
            description = "注册验证码"
    )
    public Result<Void> sms(@Validated @RequestBody RegisterSmsRequest request) {
        registerService.sms(request);
        return Result.success();
    }

}
